package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.renderscript.ScriptGroup;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemLeaseHomeRecommendBinding;
import com.sgb.kjwl.databinding.ItemLeaseOrderStateBinding;
import com.sgb.kjwl.model.entity.LeaseHomeRecommendEntity;
import com.sgb.kjwl.model.entity.ShowMachineEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.DateUtils;

import java.util.List;

/**
 * 租赁首页热门推荐
 */
public class LeaseHomeRecommendAdapter extends BaseRecycleAdapter<LeaseHomeRecommendEntity> {

    private ItemLeaseHomeRecommendBinding binding;

    public LeaseHomeRecommendAdapter(Context context, List<LeaseHomeRecommendEntity> datas) {
        super(context, R.layout.item_lease_home_recommend, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final LeaseHomeRecommendEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        binding = (ItemLeaseHomeRecommendBinding) holder.getmBinding();
        binding.tvIsSelf.setVisibility("1".equals(entity.getIsSelf()) ? View.VISIBLE : View.INVISIBLE);
        if ("1".equals(entity.getNegotiable())) {
            binding.priceView.setText("面议");
        } else {
            binding.priceView.setText(entity.getPrice() + entity.getPriceUnit());
        }
        binding.tvArea.setText(entity.getCity() + entity.getArea());
        try {
            binding.tvTime.setText(DateUtils.stampToDay(entity.getUpdatetime()));
        } catch (Exception e) {
        }
    }

}
